using System.Collections;
using Audio;
using Level;
using UnityEngine;
using UnityEngine.Localization.Settings;
using UnityEngine.UI;

namespace UI
{
    public class StartMenu : MonoBehaviour
    {
        [SerializeField] private SceneLoader sceneLoader;
        [SerializeField] private Button startButton;
        [SerializeField] private Button exitButton;
        
        private readonly int _gameSceneIndex = 1;


        private void Start()
        {
            startButton.onClick.AddListener(StartGame);
            exitButton.onClick.AddListener(ExitGame);
            
            AudioPlayer.Instance.SetVolume(0.5f);
            
        #if UNITY_WEBGL
            exitButton.gameObject.SetActive(false);
        #endif
        }

        private void ExitGame()
        {
#if UNITY_EDITOR
            UnityEditor.EditorApplication.isPlaying = false;
#else
            Application.Quit();
#endif
        }

        private void StartGame()
        {
            startButton.onClick.RemoveListener(StartGame);
            sceneLoader.LoadScene(_gameSceneIndex);
        }
    }
}